﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Entity;

namespace StudentInfo.Security.Services
{
    public class RoleService
    {
        public static List<Role> GetByUser(Guid id)
        {
            using (var context = new StudentInfoEntities())
            {
                return context.Roles
                    .Include(x => x.RolePermissions)
                    .Where(x => x.Users.FirstOrDefault(y => y.Id == id) != null).ToList();
            }
        }
    }
}